<ul class="list-group post-list">
    {% for post in posts %}
        <li class="list-group-item">
            {% set postUrl = post.category.isBook ?
            path('book_read', {'slug': post.category.slug, 'chapterId': post.id}) :  path('post_view', {'id': post.id}) %}
            {% set authorUrl = path('user_view', {'username': post.user.username}) %}
            <article class="media post clearfix" role="article">
                <div class="media-body content-box">
                    <div class="author">
                        <a class="avatar" href="{{ authorUrl }}"><img src="{{ asset(post.user.avatar)|imagine_filter('middle_square') }}" class="img-circle img-responsive"></a>
                        <span class="username"><a href="{{ authorUrl }}">{{ post.user.username }}</a></span>
                        <span class="meta">{{ 'post.publish_at'|trans }}</span>
                        {% if post.category.isBook %}
                            <a class="category" href="{{ path('book_view', {'slug': post.category.slug}) }}">
                                <i class="fa fa-book meta"></i> {{ post.category.name }}
                            </a>
                        {% else %}
                            <a class="category" href="{{ path('category_view', {'slug': post.category.slug}) }}">{{ post.category.name }}</a>
                        {% endif %}
                        <time class="publish-time hidden"><i class="if i-calendar"></i> {{ post.createdAt|time_diff }}</time>
                    </div>
                    <h3 class="title">
                        {% if post.isRecommended %}
                            <span class="sticky-tag">{{ 'post.recommend'|trans }}</span>
                        {% endif %}
                        <a href="{{ postUrl }}">
                            <span>{{ post.title }}</span>
                        </a>
                    </h3>
                    <div class="summary">{{ post.summary }}</div>
                    <ul class="list-unstyled list-inline meta" data-role="post-action">
                        <li><a href="{{ postUrl }}#comments"><i class="if i-comment"></i> {{ post.commentCount }}</a></li>
                        <li><i class="if i-view"></i> {{ post.viewCount }}</li>
                        {% if is_granted('edit', post) %}
                            <li><a href="{{ path('post_edit', {id: post.id}) }}" title="{{ 'ui.edit'|trans }}"><i class="if i-edit"></i> {{ 'ui.edit'|trans }}</a></li>
                        {% endif %}
                    </ul>
                </div>
                {% if post.images %}
                    <div class="media-right media-middle cover">
                        <a href="{{ postUrl }}" title="{{ post.title }}">
                            <img src="{{ post.images[0] }}" class="media-object">
                        </a>
                    </div>
                {% endif %}
            </article>
        </li>
    {% else %}
        <li class="list-group-item empty-data">
            <p><i class="if i-post-o"></i> {{ 'post.empty'|trans }}</p>
        </li>
    {% endfor %}
</ul>